package rsj.api.orgp;

import com.rlyy.aibase.db.Dbink;
import com.rlyy.aibase.utils.base.Box;
import com.rlyy.aibase.utils.base.MapNode;
import com.rlyy.aibase.utils.base.ThinkException;
import common.util.BoxUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rsj.api.user.BaseLink;
import rsj.db.PostgresqlConn;
import rsj.service.OrgpService;

import java.sql.Connection;
import java.sql.SQLException;
@RestController
public class RechargeList extends BaseLink{
	@Autowired
	private OrgpService orgpInfoService;

	@RequestMapping(value = "rsj_prod_rechargeList")
	public Box executeLink(Box in) throws ThinkException {

		MapNode data = in.getMapNode("data");
		MapNode map ;
		Connection conn = PostgresqlConn.getConnection();

		try {
			map =orgpInfoService.rechargeList(conn, data);
		} catch (SQLException e) {
			logger.error("invoke--->" + in.getApi() + " error "
                    + ", arguments is " + in.toJson() , e);
            //return BoxUtil.errorBox(in,  "错误原因::" + e.getMessage());
            return BoxUtil.errorBox(in,  "服务器忙！" );
		}finally {
            Dbink.close(conn);
        }


		return BoxUtil.successBox(in, "查询成功！").putMapNode("data", map);
	}


}
